#   Author: zhangruonan

import math
import geopy
from geographiclib.geodesic import Geodesic
'''
def get_lat_lon(start_lat, start_lon,distance,direction):
        start = geopy.Point(start_lat, start_lon)
        d = geodesic(meters=distance)
        p = d.destination(point=start, bearing=direction)
        return p.longitude, p.latitude
'''
if __name__=="__main__":

    #c34:
    p0 = [120.63983669444444,31.42807566666667]
    p1 = [120.64001433333334,31.42800188888889]
    p2 = [120.64011872222223,31.427956944444446]
    p3 = [120.6401241388889,31.4279025]
    p4 = [120.64008777777778,31.427810416666667]
    p5 = [120.64000944444444,31.42787211111111]
    p6 = [120.64007505555556,31.427914055555554]
    p7 = [120.64001091666667,31.427985694444445]
    p8 = [120.63996144444444,31.427970583333334]
    #p9 = [117.9699159,24.4568227]
    g1 = Geodesic.WGS84.Inverse(p0[1], p0[0], p1[1], p1[0])
    g2 = Geodesic.WGS84.Inverse(p0[1], p0[0], p2[1], p2[0])
    g3 = Geodesic.WGS84.Inverse(p0[1], p0[0], p3[1], p3[0])
    g4 = Geodesic.WGS84.Inverse(p0[1], p0[0], p4[1], p4[0])
    g5 = Geodesic.WGS84.Inverse(p0[1], p0[0], p5[1], p5[0])
    g6 = Geodesic.WGS84.Inverse(p0[1], p0[0], p6[1], p6[0])
    g7 = Geodesic.WGS84.Inverse(p0[1], p0[0], p7[1], p7[0])
    g8 = Geodesic.WGS84.Inverse(p0[1], p0[0], p8[1], p8[0])
    #print(g1['s12'],g1['azi2'])
    wx1 = g1['s12'] * math.sin(math.radians(g1['azi2']))
    wy1 = g1['s12'] * math.cos(math.radians(g1['azi2']))
    wx2 = g2['s12'] * math.sin(math.radians(g2['azi2']))
    wy2 = g2['s12'] * math.cos(math.radians(g2['azi2']))
    wx3 = g3['s12'] * math.sin(math.radians(g3['azi2']))
    wy3 = g3['s12'] * math.cos(math.radians(g3['azi2']))
    wx4 = g4['s12'] * math.sin(math.radians(g4['azi2']))
    wy4 = g4['s12'] * math.cos(math.radians(g4['azi2']))
    wx5 = g5['s12'] * math.sin(math.radians(g5['azi2']))
    wy5 = g5['s12'] * math.cos(math.radians(g5['azi2']))
    wx6 = g6['s12'] * math.sin(math.radians(g6['azi2']))
    wy6 = g6['s12'] * math.cos(math.radians(g6['azi2']))
    wx7 = g7['s12'] * math.sin(math.radians(g7['azi2']))
    wy7 = g7['s12'] * math.cos(math.radians(g7['azi2']))
    wx8 = g8['s12'] * math.sin(math.radians(g8['azi2']))
    wy8 = g8['s12'] * math.cos(math.radians(g8['azi2']))

    print(wx1,wy1,'\n',
          wx2,wy2,'\n',
          wx3,wy3,'\n',
          wx4,wy4,'\n',
          wx5,wy5,'\n',
          wx6,wy6,'\n',
          wx7,wy7,'\n',
          wx8,wy8)
